var util = require('../../../libs/util.js');
//获取应用实例
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    receive_time: '00:00'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    if (e.id) {
      this.setData({
        id: e.id
      })
    }
  },
  bindInput: function (e) {
    var item = String(e.currentTarget.id), item_value = {};
    item_value[item] = e.detail.value;
    this.setData(item_value);
  },
  loadData: function () {
    var that = this;
  },
  backToList: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  formSubmit: function () {
    var that = this;
    var dataList = that.data.dataList;
    if(!that.data.CO_NAME){
      wx.showToast({
        title: "请输入名称",
        image: '/images/wrong.png',
        duration: 3000
      });
      return false;
    }
    util.postData("/atapi/enterprise/enterprise/newCompany", {
      'CO_NAME': that.data.CO_NAME,
      'system_vip': that.data.system_vip||0,
      'business_vip': that.data.business_vip||0,
      'vehicle_vip': that.data.vehicle_vip||0,
      'lab_vip': that.data.lab_vip||0,
      'is_login': that.data.is_login||0,
      'warehouse_shop': that.data.warehouse_shop||0,
      'appkey': that.data.appkey||'',
      'appsecret': that.data.appsecret||'',
      'auto_copy_delivery': that.data.auto_copy_delivery||0,
      'auto_copy_delivery_date': that.data.auto_copy_delivery_date||'',
      'auto_copy_delivery_time': that.data.auto_copy_delivery_time||'',
      'auto_copy_delivery_vehicle': that.data.auto_copy_delivery_vehicle||'',
      'auto_reach': that.data.auto_reach||0,
      'day_report_date': that.data.day_report_date||'',
      'day_report_lastdate': that.data.day_report_lastdate||'',
      'day_report_push': that.data.day_report_push||0,
      'day_report_time': that.data.day_report_time||'',
      'price_schedule_show': that.data.price_schedule_show||1,
      'shopImportMode': that.data.shopImportMode||'name',
      'system_service_charge': that.data.system_service_charge||0,
      'taxrate': that.data.taxrate||0,
      'work_before_check': that.data.work_before_check||0
    }, function (res, error) {
      console.log(res); console.log(error)
      if (res.data.success) {
        wx.showToast({
          title: "提交成功",
          icon: "success",
          duration: 3000,
          success: function () {
            setTimeout(function () {
              wx.redirectTo({
                url: '/pages/enterprise/super/company'
              })
            }, 3000);
          }
        });
      } else {
        wx.showToast({
          title: res.data.data,
          image: '/images/wrong.png',
          duration: 3000
        });
      }
    });
  },
  buildappkey:function(){
    this.setData({
      appkey:util.newguid(),
      appsecret:util.newguid()
    })
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})